package com.woniuxy.controller;

import com.woniuxy.entity.ExamPublish;
import com.woniuxy.entity.PaperObject;
import com.woniuxy.entity.Question;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.service.CorrectExamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author 罗蔚
 * @Date 2022/5/7 14:05
 * @Description TODO
 */
@Api(tags = "批改试卷")
@RestController
@RequestMapping("/correctExamController")
public class CorrectExamController {
    @Autowired
    CorrectExamService correctExamService;

    /**
     * 展示所有考试期次（无论是否批改）
     *
     * @param currentPage
     * @param pageSize
     * @return
     */
    @ApiOperation("展式所有考试期次")
    @GetMapping("/showAll/{currentPage}/{pageSize}")
    public ResponseEntity showAll(@PathVariable int currentPage, @PathVariable int pageSize) {
        return correctExamService.showAll(currentPage, pageSize);
    }

    /**
     * 模糊查询
     *
     * @param examPublish
     * @return
     */
    @ApiOperation("查询")
    @PostMapping("/findLike/{currentPage}/{pageSize}")
    public ResponseEntity findLike(@RequestBody ExamPublish examPublish, @PathVariable int currentPage, @PathVariable int pageSize) {
        return correctExamService.findLike(examPublish, currentPage, pageSize);
    }

    /**
     * 查询学生是否被批改
     *
     * @param examPublish
     * @return
     */
    @ApiOperation("学生是否被批改")
    @PostMapping("/findExamineeIsCorrect")
    public ResponseEntity findExamineeIsCorrect(@RequestBody ExamPublish examPublish) {
        return correctExamService.findExamineeIsCorrect(examPublish);
    }

    @ApiOperation("查分数")
    @GetMapping("/findScore/{eid}/{sid}")
    public ResponseEntity findScore(@PathVariable int eid, @PathVariable int sid) {
        return correctExamService.findScore(eid, sid);
    }

    @ApiOperation("查看问题，修改选择判断")
    @GetMapping("/findQuestionAndCorrect/{eid}/{sid}")
    public ResponseEntity findQuestionAndCorrect(@PathVariable int eid, @PathVariable int sid) {
        return correctExamService.findQuestionAndCorrect(eid, sid);
    }
    @ApiOperation("提交批改")
    @PostMapping("/commitCorrect/{eid}/{sid}")
    public ResponseEntity commitCorrect(@RequestBody List<PaperObject> paperObjectList, @PathVariable int eid, @PathVariable int sid) {
//        System.out.println(eid+"..."+sid);
//        paperObjectList.forEach(System.out::println);
        return correctExamService.commitCorrect(paperObjectList, eid, sid);
    }



}
